#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1e6 + 5, L = 5e3 + 5;
int n, m, p, s[L][L], f[L], g[L], *F, *G, fac[N] = {1}, A[N] = {1};

signed main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("CF140E New Year Garland.in", "r", stdin);
  freopen("CF140E New Year Garland.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d", &n, &m, &p);
  for (int i = 1; i <= m; ++i)
    fac[i] = 1ll * fac[i - 1] * i % p, A[i] = 1ll * A[i - 1] * (m - i + 1) % p;

  s[0][0] = 1;
  for (int i = 1; i < L; ++i)
    for (int j = 1; j <= i && j <= m; ++j) {
      s[i][j] = 1ll * (j - 1) * s[i - 1][j] % p + s[i - 1][j - 1];
      if (s[i][j] >= p) s[i][j] -= p;
    }

  F = f, G = g;
  g[0] = 1;
  int sum = 1;
  for (int i = 1, l; i <= n; ++i) {
    scanf("%d", &l);
    for (int j = 1; j <= l; ++j) {
      F[j] = 1ll * s[l][j] *
             ((1ll * A[j] * sum % p - 1ll * fac[j] * G[j] % p) % p) % p;
      if (F[j] < 0) F[j] += p;
    }
    sum = 0;
    for (int j = 1; j <= l; ++j) {
      sum += F[j];
      if (sum >= p) sum -= p;
    }
    std::swap(F, G);
    memset(F, 0, sizeof(int) * L);
  }
  printf("%d", sum);
  return 0;
}